package com.chinasofti.login.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.chinasofti.login.entity.User;

public class ToIndexController extends HttpServlet {
private static Log logger = LogFactory.getLog(ToIndexController.class);
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HttpSession session = req.getSession();
		User account = (User) session.getAttribute("user");
		if(account!=null){
			String login_sIndex = "index/index.jsp";
			resp.sendRedirect(login_sIndex);
		}else{
			String login_fail = "login/login_fail.jsp";
			resp.sendRedirect(login_fail);
		}
		return;
	}
}
